<template>
  <view class="wrapper">
    <view
        v-for="(item, index) in list"
        :key="index"
        class="list-item"
    >
      <view class="item" @click="viewProduct(item)">
        <view class="image">
          <u--image width="100%" height="150rpx" :fade="true" duration="450" lazy-load mode="scaleToFill" :src="baseUrL + item.mainImage.thumbnail_path" v-if="item.mainImage" />
        </view>
        <div class="name">{{ item.title }}</div>
      </view>
    </view>
  </view>
</template>

<script>
import config from '../../../config/config'
export default {
  props: ['list'],
  data() {
    return {
      baseUrL: config.baseUrl
    }
  },
  methods: {
    // 产品详情页
    viewProduct(item) {
      uni.navigateTo({
        url: `/sub_product/detail/index?id=${item.id}`
      })
    }
  }
}
</script>

<style scoped lang="scss">
.wrapper {
  padding: 10rpx;
  display: flex;
  flex-wrap: wrap;
  width: 100%;
  .list-item {
    width: 33.33%;
    box-sizing: border-box;
    .item {
      display: flex;
      flex-direction: column;
      justify-content: center;
      //min-height: 120px;
      //background: blue;
      .image {
        padding: 10rpx;
        //background: red;
        flex: 1;
        image {
          width: 100%;
          height: 100%;
          display: block;
          margin: auto;
        }
      }
      .name {
        height: 20px;
        line-height: 20px;
        text-align: center;
        //font-size: 24rpx;
        //background: red;
        overflow: hidden;
        //font-weight: 700;
      }
    }
  }
}
</style>
